//
//  Row2Label.m
//  AppleMarket
//
//  Created by yangy on 29/10/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "Row2Label.h"

@interface Row2Label()
@property (nonatomic, strong) UILabel *topLabel;
@property (nonatomic, strong) UILabel *downLabel;
@property (nonatomic, strong) UIImageView *iconView;
@end

@implementation Row2Label

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        [self addSubview:self.topLabel];
        [self addSubview:self.downLabel];
        [self addSubview:self.iconView];
        
        [_topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.mas_left).offset(16);
            //make.centerX.mas_equalTo(self);
            make.bottom.mas_equalTo(self.mas_centerY).offset(-7);
        }];
        
        [_downLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.mas_left).offset(16);
            make.top.mas_equalTo(self.mas_centerY).offset(7);
            make.centerX.mas_equalTo(self);
        }];
    
        [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.topLabel.mas_right).offset(8);
            make.centerY.mas_equalTo(self.topLabel.mas_centerY);
//            make.size.mas_equalTo(CGSizeMake(6, 10));
        }];
    }
    return self;
}

- (UILabel *)topLabel
{
    if(!_topLabel){
        _topLabel = [UILabel cm_labelWithText:@"" font:kFont(13) textColor:kColorWithHex(0x3291EB)];
    }
    return _topLabel;
}
- (UILabel *)downLabel
{
    if(!_downLabel){
        _downLabel = [UILabel cm_labelWithText:@"" font:kFontBold(15) textColor:kColorWithHex(0x0E304C)];
    }
    return _downLabel;
}

- (UIImageView *)iconView
{
    if(!_iconView){
        _iconView = [[UIImageView alloc] init];
    }
    return _iconView;
}

- (void) setTopText:(NSString*) text image:(UIImage*) image
{
    _topLabel.text = text;
    _iconView.image = image;
}

- (void) setDownAttrText:(NSAttributedString*) attributeText
{
    _downLabel.attributedText = attributeText;
}
@end
